<?php
// 登录页
// header("content-type:text/html;charset=utf-8");
$ID = $_POST['admID'];
$pwd = $_POST['admPwd'];
include_once("conn.php");

//设置中国时区
date_default_timezone_set('Asia/Shanghai');
// 获取当前日期
$getTime = date('Y-m-d H:i:s');

$sql = "SELECT * FROM admin_infos WHERE admin_ID = '" . $ID . "'";
$result = mysqli_query($connect_DB, $sql);
$rows = mysqli_num_rows($result);
if ($rows != 0) {
    $admin_Info = mysqli_fetch_object($result);
    if ($pwd === $admin_Info->admin_Password) {
        $update = "UPDATE admin_infos SET admin_LastLoginTime = '".$admin_Info->admin_LoginTime."' , admin_LoginTime = '".$getTime."' WHERE admin_ID = '" . $ID . "'";
        $result_update = mysqli_query($connect_DB, $update);
        // 登录成功，将用户信息存入session
        $admin_Info = mysqli_fetch_object(mysqli_query($connect_DB, $sql));
        session_start();
        $_SESSION['admin_info'] = $admin_Info;
        echo "<script>alert('登录成功！');location='admin_PersonBasicInfo.php';</script>";
    } else {
        echo "<script>alert('密码错误！请重试！');history.go(-1);</script>";
    }
}else{
    echo "<script>alert('账号不存在！');history.go(-1);</script>";
}
$connect_DB->close();

?>